<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>IDEA 自带 database 侧边栏生成JavaBean | 小波的博客</title><meta name="keywords" content="工具篇"><meta name="author" content="Steve"><meta name="copyright" content="Steve"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="1、连接数据库database 可连接 MySQL、MongoDB、MariaDB 等，如下图   目前以 MySQL 数据库为例，配置驱动   URL&#x3D;jdbc:mysql:&#x2F;&#x2F;localhost:3306&#x2F;你的数据库名?useUnicode&#x3D;true&amp;characterEncoding&#x3D;utf8&amp;serverTimezone&#x3D;UTC 2.数据库中的结构  2.1、工具栏介绍">
<meta property="og:type" content="article">
<meta property="og:title" content="IDEA 自带 database 侧边栏生成JavaBean">
<meta property="og:url" content="https://steve6636.gitee.io/2021/05/26/IDEA%20%E8%87%AA%E5%B8%A6%20database%20%E4%BE%A7%E8%BE%B9%E6%A0%8F%E7%94%9F%E6%88%90JavaBean/index.html">
<meta property="og:site_name" content="小波的博客">
<meta property="og:description" content="1、连接数据库database 可连接 MySQL、MongoDB、MariaDB 等，如下图   目前以 MySQL 数据库为例，配置驱动   URL&#x3D;jdbc:mysql:&#x2F;&#x2F;localhost:3306&#x2F;你的数据库名?useUnicode&#x3D;true&amp;characterEncoding&#x3D;utf8&amp;serverTimezone&#x3D;UTC 2.数据库中的结构  2.1、工具栏介绍">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg">
<meta property="article:published_time" content="2021-05-26T01:33:49.000Z">
<meta property="article:modified_time" content="2021-08-07T13:18:54.842Z">
<meta property="article:author" content="Steve">
<meta property="article:tag" content="工具篇">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://steve6636.gitee.io/2021/05/26/IDEA%20%E8%87%AA%E5%B8%A6%20database%20%E4%BE%A7%E8%BE%B9%E6%A0%8F%E7%94%9F%E6%88%90JavaBean/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'mediumZoom',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-08-07 21:18:54'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const fontSizeVal = saveToLocal.get('global-font-size')
    if (fontSizeVal !== undefined) {
      document.documentElement.style.setProperty('--global-font-size', fontSizeVal + 'px')
    }
    })(window)</script><meta name="generator" content="Hexo 5.4.0"><link rel="alternate" href="/atom.xml" title="小波的博客" type="application/atom+xml">
</head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210327175316.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">26</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">11</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">9</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> Link</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 工具箱</span></a></div><div class="menus_item"><a class="site-page" href="/friends"><i class="fa-fw fas fa-address-book"></i><span> Friends</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">小波的博客</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> Link</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 工具箱</span></a></div><div class="menus_item"><a class="site-page" href="/friends"><i class="fa-fw fas fa-address-book"></i><span> Friends</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">IDEA 自带 database 侧边栏生成JavaBean</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-05-26T01:33:49.000Z" title="发表于 2021-05-26 09:33:49">2021-05-26</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-08-07T13:18:54.842Z" title="更新于 2021-08-07 21:18:54">2021-08-07</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/">环境搭建</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.7k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>9分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="1、连接数据库"><a href="#1、连接数据库" class="headerlink" title="1、连接数据库"></a>1、连接数据库</h2><p>database 可连接 MySQL、MongoDB、MariaDB 等，如下图</p>
<img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093450.png" alt="image-20210518231939130" style="zoom: 50%;" />

<p>目前以 MySQL 数据库为例，配置驱动</p>
<img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093459.png" alt="image-20210518232309307" style="zoom:50%;" />

<p><code>URL=jdbc:mysql://localhost:3306/你的数据库名?useUnicode=true&amp;characterEncoding=utf8&amp;serverTimezone=UTC</code></p>
<h2 id="2-数据库中的结构"><a href="#2-数据库中的结构" class="headerlink" title="2.数据库中的结构"></a>2.数据库中的结构</h2><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093503.png" alt="image-20210518232426063" style="zoom:50%;" />

<h3 id="2-1、工具栏介绍"><a href="#2-1、工具栏介绍" class="headerlink" title="2.1、工具栏介绍"></a>2.1、工具栏介绍</h3><p><img src= "/img/loading.gif" data-lazy-src="D:\NodeJS\HelloHexo\source_posts\image-20210518234424264.png" alt="image-20210518234424264"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093506.png" alt="image-20210518234710269"></p>
<h3 id="2-2查看数据表视图"><a href="#2-2查看数据表视图" class="headerlink" title="2.2查看数据表视图"></a>2.2查看数据表视图</h3><p>Table 视图</p>
<img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093509.png" alt="image-20210518232919113" style="zoom:50%;" />

<p>Tree 视图</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093512.png" alt="image-20210518234453899"></p>
<p>Text 视图</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093514.png" alt="image-20210518234542436"></p>
<h3 id="2-3、Data-Extractors-数据提取器介绍"><a href="#2-3、Data-Extractors-数据提取器介绍" class="headerlink" title="2.3、Data Extractors 数据提取器介绍"></a>2.3、Data Extractors 数据提取器介绍</h3><p><img src= "/img/loading.gif" data-lazy-src="D:\NodeJS\HelloHexo\source_posts\image-20210518235611567.png" alt="image-20210518235611567"></p>
<p>1）SQL Inserts ：将数据以 插入 INSERT 语句格式显示，如图</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093516.png" alt="image-20210518235822368"></p>
<p>2）SQL Updates：将数据以 插入 updates语句格式显示，如图</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093519.png" alt="image-20210519000005084"></p>
<p>3）Tab-separated (TSV)：</p>
<p>Comma-separated (CSV)：以 csv 格式显示数据</p>
<p>csv 格式也显示同样格式</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093523.png" alt="image-20210519000147231"></p>
<p>4）Configure CSV Formats..</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093527.png" alt="image-20210519000233083"></p>
<p>5）HTML (groovy)</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093531.png" alt="image-20210519000641045"></p>
<p>6）HTML（js）：以 js 格式提取数据</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093535.png" alt="image-20210519000732758"></p>
<p>7）json</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093539.png" alt="image-20210519000816415"></p>
<p>8）Markdown</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093541.png" alt="image-20210519000834877"></p>
<p>9）Pretty：美化 Markdown 格式</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093544.png" alt="image-20210519000906836"></p>
<p>10）SQL-lnsert-Statements：将数据以 插入 insert 语句格式显示，如图，关键字小写</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093547.png" alt="image-20210519000954766"></p>
<p>11）XML</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093551.png" alt="image-20210519001137479"></p>
<p>12）GO to Scripts Directory：跳转到脚本目录</p>
<img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093554.png" alt="image-20210519001223382" style="zoom:50%;" />

<h2 id="3、生成实体类"><a href="#3、生成实体类" class="headerlink" title="3、生成实体类"></a>3、生成实体类</h2><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093559.png" alt="image-20210519001321623" style="zoom:50%;" />

<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093603.png" alt="image-20210519001743555"></p>
<p>生成的实体类文件</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093622.png" alt="image-20210519001853891"></p>
<h3 id="3-1-配置-groovy-文件"><a href="#3-1-配置-groovy-文件" class="headerlink" title="3.1 配置 .groovy 文件"></a><strong>3.1 配置 .groovy 文件</strong></h3><h4 id="1）打开-groovy-文件所在目录"><a href="#1）打开-groovy-文件所在目录" class="headerlink" title="1）打开 .groovy 文件所在目录"></a>1）打开 .groovy 文件所在目录</h4><p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093921.png" alt="image-20210526093920140"></p>
<p><img src= "/img/loading.gif" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210526093944.png" alt="image-20210526093942907"></p>
<h4 id="2）新建-groovy-文件"><a href="#2）新建-groovy-文件" class="headerlink" title="2）新建 .groovy 文件"></a>2）新建 .groovy 文件</h4><p>在 schema 目录下新建一个名为 MyGenerate POJOs.groovy 的文件，文件名可以自定义</p>
<p>在 MyGenerate POJOs.groovy 中添加如下代码：</p>
<figure class="highlight groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> com.intellij.database.model.DasTable</span><br><span class="line"><span class="keyword">import</span> com.intellij.database.model.ObjectKind</span><br><span class="line"><span class="keyword">import</span> com.intellij.database.util.Case</span><br><span class="line"><span class="keyword">import</span> com.intellij.database.util.DasUtil</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.text.SimpleDateFormat</span><br><span class="line"></span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment"> *   Available context bindings:</span></span><br><span class="line"><span class="comment"> *   SELECTION   Iterable&lt;DasObject&gt;</span></span><br><span class="line"><span class="comment"> *   PROJECT     project</span></span><br><span class="line"><span class="comment"> *   FILES       files helper</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line">packageName = <span class="string">&quot;&quot;</span></span><br><span class="line">typeMapping = [</span><br><span class="line">        (<span class="regexp">~/(?i)tinyint|smallint|mediumint|int/</span>)  : <span class="string">&quot;Integer&quot;</span>,</span><br><span class="line">        (<span class="regexp">~/(?i)bigint/</span>)                          : <span class="string">&quot;Long&quot;</span>,</span><br><span class="line">        (<span class="regexp">~/(?i)bool|bit/</span>)                        : <span class="string">&quot;Boolean&quot;</span>,</span><br><span class="line">        (<span class="regexp">~/(?i)float|double|decimal|real/</span>)       : <span class="string">&quot;Double&quot;</span>,</span><br><span class="line">        (<span class="regexp">~/(?i)datetime|timestamp|date|time/</span>)    : <span class="string">&quot;Date&quot;</span>,</span><br><span class="line">        (<span class="regexp">~/(?i)blob|binary|bfile|clob|raw|image/</span>): <span class="string">&quot;InputStream&quot;</span>,</span><br><span class="line">        (<span class="regexp">~/(?i)/</span>)                                : <span class="string">&quot;String&quot;</span></span><br><span class="line">]</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">FILES.chooseDirectoryAndSave(<span class="string">&quot;Choose directory&quot;</span>, <span class="string">&quot;Choose where to store generated files&quot;</span>) &#123; dir -&gt;</span><br><span class="line">    SELECTION.filter &#123; it <span class="keyword">instanceof</span> DasTable &amp;&amp; it.getKind() == ObjectKind.TABLE &#125;.each &#123; generate(it, dir) &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">def</span> generate(table, dir) &#123;</span><br><span class="line">    <span class="keyword">def</span> className = javaName(table.getName(), <span class="literal">true</span>)</span><br><span class="line">    <span class="keyword">def</span> fields = calcFields(table)</span><br><span class="line">    packageName = getPackageName(dir)</span><br><span class="line">    PrintWriter printWriter = <span class="keyword">new</span> PrintWriter(<span class="keyword">new</span> OutputStreamWriter(<span class="keyword">new</span> FileOutputStream(<span class="keyword">new</span> File(dir, className + <span class="string">&quot;.java&quot;</span>)), <span class="string">&quot;UTF-8&quot;</span>))</span><br><span class="line">    printWriter.withPrintWriter &#123; out -&gt; generate(out, className, fields, table) &#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//    new File(dir, className + &quot;.java&quot;).withPrintWriter &#123; out -&gt; generate(out, className, fields,table) &#125;</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 获取包所在文件夹路径</span></span><br><span class="line"><span class="keyword">def</span> getPackageName(dir) &#123;</span><br><span class="line">    <span class="comment">// package .com.alibaba.bean; 最后的replaceAll 去除 &quot;.com&quot; 中的点</span></span><br><span class="line">    <span class="keyword">return</span> dir.toString().replaceAll(<span class="string">&quot;\\\\&quot;</span>, <span class="string">&quot;.&quot;</span>).replaceAll(<span class="string">&quot;/&quot;</span>, <span class="string">&quot;.&quot;</span>).replaceAll(<span class="string">&quot;^.*src(\\.main\\.java\\.)?&quot;</span>, <span class="string">&quot;&quot;</span>).replaceFirst(<span class="string">&quot;.&quot;</span>,<span class="string">&quot;&quot;</span>) + <span class="string">&quot;;&quot;</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">def</span> generate(out, className, fields, table) &#123;</span><br><span class="line">    out.println <span class="string">&quot;package $packageName&quot;</span></span><br><span class="line">    out.println <span class="string">&quot;&quot;</span></span><br><span class="line">    out.println <span class="string">&quot;import javax.persistence.Column;&quot;</span></span><br><span class="line">    out.println <span class="string">&quot;import javax.persistence.Entity;&quot;</span></span><br><span class="line">    out.println <span class="string">&quot;import javax.persistence.Table;&quot;</span></span><br><span class="line"><span class="comment">//    out.println &quot;import javax.persistence.Id;&quot;</span></span><br><span class="line"><span class="comment">//    out.println &quot;import javax.persistence.GeneratedValue;&quot;</span></span><br><span class="line">    out.println <span class="string">&quot;import java.io.Serializable;&quot;</span></span><br><span class="line">    Set types = <span class="keyword">new</span> HashSet()</span><br><span class="line"></span><br><span class="line">    fields.each() &#123;</span><br><span class="line">        types.add(it.type)</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (types.contains(<span class="string">&quot;Date&quot;</span>)) &#123;</span><br><span class="line">        out.println <span class="string">&quot;import java.util.Date;&quot;</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (types.contains(<span class="string">&quot;InputStream&quot;</span>)) &#123;</span><br><span class="line">        out.println <span class="string">&quot;import java.io.InputStream;&quot;</span></span><br><span class="line">    &#125;</span><br><span class="line">    out.println <span class="string">&quot;&quot;</span></span><br><span class="line">    out.println <span class="string">&quot;/**\n&quot;</span> +</span><br><span class="line">            <span class="string">&quot; * @Author  steve\n&quot;</span> +  <span class="comment">//1. 修改idea为自己名字</span></span><br><span class="line">            <span class="string">&quot; * @Create &quot;</span> + <span class="keyword">new</span> SimpleDateFormat(<span class="string">&quot;yyyy-MM-dd HH:mm:ss&quot;</span>).format(<span class="keyword">new</span> Date()) + <span class="string">&quot; \n&quot;</span> +</span><br><span class="line">            <span class="string">&quot; * @Description  \n&quot;</span> +</span><br><span class="line">            <span class="string">&quot; */&quot;</span></span><br><span class="line">    out.println <span class="string">&quot;&quot;</span></span><br><span class="line">    out.println <span class="string">&quot;@Entity // maven 导入 javax.persistence-api 依赖 ，必须与@Id注解 结合使用  否则  No identifier specified for entity&quot;</span></span><br><span class="line">    out.println <span class="string">&quot;@Table ( name =\&quot;&quot;</span> + table.getName() + <span class="string">&quot;\&quot; , schema = \&quot;\&quot;)&quot;</span> <span class="comment">//2. schema = \&quot;后面添加自己的表空间名称(mysql可以不添加, 不用这个schema属性也行)</span></span><br><span class="line">    out.println <span class="string">&quot;public class $className  implements Serializable &#123;&quot;</span></span><br><span class="line">    out.println <span class="string">&quot;&quot;</span></span><br><span class="line">    out.println genSerialID()</span><br><span class="line">    fields.each() &#123;</span><br><span class="line">        out.println <span class="string">&quot;&quot;</span></span><br><span class="line">        <span class="comment">// 输出数据库的字段注释</span></span><br><span class="line">        <span class="keyword">if</span> (isNotEmpty(it.commoent)) &#123;</span><br><span class="line">            out.println <span class="string">&quot;\t/**&quot;</span></span><br><span class="line">            out.println <span class="string">&quot;\t * $&#123;it.commoent.toString()&#125;&quot;</span></span><br><span class="line">            out.println <span class="string">&quot;\t */&quot;</span></span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="keyword">if</span> ((it.annos+<span class="string">&quot;&quot;</span>).indexOf(<span class="string">&quot;[@Id]&quot;</span>) &gt;= <span class="number">0</span>) out.println <span class="string">&quot;\t@Id&quot;</span></span><br><span class="line"></span><br><span class="line">        <span class="keyword">if</span> (it.annos != <span class="string">&quot;&quot;</span>) out.println <span class="string">&quot;   $&#123;it.annos.replace(&quot;</span>[<span class="meta">@Id</span>]<span class="string">&quot;, &quot;</span><span class="string">&quot;)&#125;&quot;</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">// 输出成员变量</span></span><br><span class="line">        out.println <span class="string">&quot;\tprivate $&#123;it.type&#125; $&#123;it.name&#125;;&quot;</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//生成无参构造函数</span></span><br><span class="line">    out.println <span class="string">&quot;&quot;</span></span><br><span class="line">    out.print <span class="string">&quot;\tpublic &quot;</span></span><br><span class="line">    out.print className</span><br><span class="line">    out.print  <span class="string">&quot;()&#123;&quot;</span></span><br><span class="line">    out.println <span class="string">&quot;&#125;&quot;</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">//生成全参构造函数</span></span><br><span class="line">    out.println <span class="string">&quot;&quot;</span></span><br><span class="line">    out.print <span class="string">&quot;\tpublic &quot;</span></span><br><span class="line">    out.print className</span><br><span class="line">    out.print  <span class="string">&quot;(&quot;</span></span><br><span class="line">    out.print getAllArgs(fields)</span><br><span class="line">    out.print  <span class="string">&quot;)&#123;&quot;</span></span><br><span class="line">    out.println <span class="string">&quot;&quot;</span></span><br><span class="line">    fields.each() &#123;</span><br><span class="line">        out.println <span class="string">&quot;\t\tthis.$&#123;it.name&#125; = $&#123;it.name&#125;;&quot;</span></span><br><span class="line">    &#125;</span><br><span class="line">    out.println <span class="string">&quot;&#125;&quot;</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 输出toString方法</span></span><br><span class="line">    out.println <span class="string">&quot;&quot;</span></span><br><span class="line">    out.println <span class="string">&quot;\t@Override&quot;</span></span><br><span class="line">    out.println <span class="string">&quot;\tpublic String toString() &#123;&quot;</span></span><br><span class="line">    out.println <span class="string">&quot;\t\treturn \&quot;&quot;</span> + className + <span class="string">&quot;&#123;\&quot; +&quot;</span></span><br><span class="line">    fields.each() &#123;</span><br><span class="line">        out.println <span class="string">&quot;\t\t\t\t\&quot;, $&#123;it.name&#125;=&#x27;\&quot; + $&#123;it.name&#125; + &#x27;\\&#x27;&#x27; +&quot;</span></span><br><span class="line">    &#125;</span><br><span class="line">    out.println <span class="string">&quot;\t\t\t\t&#x27;&#125;&#x27;;&quot;</span></span><br><span class="line">    out.println <span class="string">&quot;\t&#125;&quot;</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 输出get/set方法</span></span><br><span class="line">    fields.each() &#123;</span><br><span class="line">        out.println <span class="string">&quot;&quot;</span></span><br><span class="line">        out.println <span class="string">&quot;\tpublic $&#123;it.type&#125; get$&#123;it.name.capitalize()&#125;() &#123;&quot;</span></span><br><span class="line">        out.println <span class="string">&quot;\t\treturn this.$&#123;it.name&#125;;&quot;</span></span><br><span class="line">        out.println <span class="string">&quot;\t&#125;&quot;</span></span><br><span class="line">        out.println <span class="string">&quot;&quot;</span></span><br><span class="line"></span><br><span class="line">        out.println <span class="string">&quot;\tpublic void set$&#123;it.name.capitalize()&#125;($&#123;it.type&#125; $&#123;it.name&#125;) &#123;&quot;</span></span><br><span class="line">        out.println <span class="string">&quot;\t\tthis.$&#123;it.name&#125; = $&#123;it.name&#125;;&quot;</span></span><br><span class="line">        out.println <span class="string">&quot;\t&#125;&quot;</span></span><br><span class="line">    &#125;</span><br><span class="line">    out.println <span class="string">&quot;&quot;</span></span><br><span class="line">    out.println <span class="string">&quot;&#125;&quot;</span></span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">def</span> getAllArgs(fields) &#123;</span><br><span class="line">    StringBuilder AllArgs = <span class="keyword">new</span> StringBuilder()</span><br><span class="line">    fields.each() &#123;</span><br><span class="line">        AllArgs = AllArgs.append( <span class="string">&quot;$&#123;it.type&#125; $&#123;it.name&#125;, &quot;</span>)</span><br><span class="line">    &#125;</span><br><span class="line"><span class="comment">//    String myRegex =</span></span><br><span class="line">    <span class="keyword">return</span> AllArgs.toString().replaceAll(<span class="string">&#x27;, $&#x27;</span>, <span class="string">&quot;&quot;</span>)</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">def</span> calcFields(table) &#123;</span><br><span class="line">    DasUtil.getColumns(table).reduce([]) &#123; fields, col -&gt;</span><br><span class="line">        <span class="keyword">def</span> spec = Case.LOWER.apply(col.getDataType().getSpecification())</span><br><span class="line"></span><br><span class="line">        <span class="keyword">def</span> typeStr = typeMapping.find &#123; p, t -&gt; p.matcher(spec).find() &#125;.value</span><br><span class="line">        <span class="keyword">def</span> comm = [</span><br><span class="line">                <span class="attr">colName :</span> col.getName(),</span><br><span class="line">                <span class="attr">name    :</span> javaName(col.getName(), <span class="literal">false</span>),</span><br><span class="line">                <span class="attr">type    :</span> typeStr,</span><br><span class="line">                <span class="symbol">commoent:</span> col.getComment(),</span><br><span class="line">                <span class="attr">annos   :</span> <span class="string">&quot;\t@Column(name = \&quot;&quot;</span> + col.getName() + <span class="string">&quot;\&quot; )&quot;</span>]</span><br><span class="line">        <span class="keyword">if</span> (<span class="string">&quot;id&quot;</span>.equals(Case.LOWER.apply(col.getName())))</span><br><span class="line">            comm.annos += [<span class="string">&quot;@Id&quot;</span>]</span><br><span class="line">        fields += [comm]</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 已经修改为使用javaName, 如果有需要可以在def className = javaName(table.getName(), true)中修改为javaClassName</span></span><br><span class="line"><span class="comment">// 处理类名（这里是因为我的表都是以t_命名的，所以需要处理去掉生成类名时的开头的T，</span></span><br><span class="line"><span class="comment">// 如果你不需要那么请查找用到了 javaClassName 这个方法的地方修改为 javaName 即可）</span></span><br><span class="line"><span class="keyword">def</span> javaClassName(str, capitalize) &#123;</span><br><span class="line">    <span class="keyword">def</span> s = com.intellij.psi.codeStyle.NameUtil.splitNameIntoWords(str)</span><br><span class="line">            .collect &#123; Case.LOWER.apply(it).capitalize() &#125;</span><br><span class="line">            .join(<span class="string">&quot;&quot;</span>)</span><br><span class="line">            .replaceAll(<span class="regexp">/[^\p&#123;javaJavaIdentifierPart&#125;[_]]/</span>, <span class="string">&quot;_&quot;</span>)</span><br><span class="line">    <span class="comment">// 去除开头的T  http://developer.51cto.com/art/200906/129168.htm</span></span><br><span class="line">    s = s[<span class="number">1.</span>.s.size() - <span class="number">1</span>]</span><br><span class="line">    capitalize || s.length() == <span class="number">1</span> ? s : Case.LOWER.apply(s[<span class="number">0</span>]) + s[<span class="number">1.</span>.<span class="number">-1</span>]</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">def</span> javaName(str, capitalize) &#123;</span><br><span class="line"><span class="comment">//    def s = str.split(/(?&lt;=[^\p&#123;IsLetter&#125;])/).collect &#123; Case.LOWER.apply(it).capitalize() &#125;</span></span><br><span class="line"><span class="comment">//            .join(&quot;&quot;).replaceAll(/[^\p&#123;javaJavaIdentifierPart&#125;]/, &quot;_&quot;)</span></span><br><span class="line"><span class="comment">//    capitalize || s.length() == 1? s : Case.LOWER.apply(s[0]) + s[1..-1]</span></span><br><span class="line">    <span class="keyword">def</span> s = com.intellij.psi.codeStyle.NameUtil.splitNameIntoWords(str)</span><br><span class="line">            .collect &#123; Case.LOWER.apply(it).capitalize() &#125;</span><br><span class="line">            .join(<span class="string">&quot;&quot;</span>)</span><br><span class="line">            .replaceAll(<span class="regexp">/[^\p&#123;javaJavaIdentifierPart&#125;[_]]/</span>, <span class="string">&quot;_&quot;</span>)</span><br><span class="line">    capitalize || s.length() == <span class="number">1</span> ? s : Case.LOWER.apply(s[<span class="number">0</span>]) + s[<span class="number">1.</span>.<span class="number">-1</span>]</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">def</span> isNotEmpty(content) &#123;</span><br><span class="line">    <span class="keyword">return</span> content != <span class="literal">null</span> &amp;&amp; content.toString().trim().length() &gt; <span class="number">0</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> String changeStyle(String str, <span class="keyword">boolean</span> toCamel) &#123;</span><br><span class="line">    <span class="keyword">if</span> (!str || str.size() &lt;= <span class="number">1</span>)</span><br><span class="line">        <span class="keyword">return</span> str</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (toCamel) &#123;</span><br><span class="line">        String r = str.toLowerCase().split(<span class="string">&#x27;_&#x27;</span>).collect &#123; cc -&gt; Case.LOWER.apply(cc).capitalize() &#125;.join(<span class="string">&#x27;&#x27;</span>)</span><br><span class="line">        <span class="keyword">return</span> r[<span class="number">0</span>].toLowerCase() + r[<span class="number">1.</span>.<span class="number">-1</span>]</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        str = str[<span class="number">0</span>].toLowerCase() + str[<span class="number">1.</span>.<span class="number">-1</span>]</span><br><span class="line">        <span class="keyword">return</span> str.collect &#123; cc -&gt; ((<span class="keyword">char</span>) cc).isUpperCase() ? <span class="string">&#x27;_&#x27;</span> + cc.toLowerCase() : cc &#125;.join(<span class="string">&#x27;&#x27;</span>)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> String genSerialID() &#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="string">&quot;\tprivate static final long serialVersionUID =  &quot;</span> + Math.abs(<span class="keyword">new</span> Random().nextLong()) + <span class="string">&quot;L;&quot;</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="3）重启-IDEA"><a href="#3）重启-IDEA" class="headerlink" title="3）重启 IDEA"></a>3）重启 IDEA</h4><h4 id="4）演示效果"><a href="#4）演示效果" class="headerlink" title="4）演示效果"></a>4）演示效果</h4><iframe height=498 width=1080 src='https://player.youku.com/embed/XNTE2MDkxNTQwMA==' frameborder=0 'allowfullscreen'></iframe>

<h4 id="5）注意事项"><a href="#5）注意事项" class="headerlink" title="5）注意事项"></a>5）注意事项</h4><p>若数据库表名为“t_”开头的，生成的 JavaBean 也会包含 T，如 Tbook</p>
<p>解决方法：可用 shift+F6 refacter-&gt;rename 一键修改</p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">Steve</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://steve6636.gitee.io/2021/05/26/IDEA%20%E8%87%AA%E5%B8%A6%20database%20%E4%BE%A7%E8%BE%B9%E6%A0%8F%E7%94%9F%E6%88%90JavaBean/">https://steve6636.gitee.io/2021/05/26/IDEA%20%E8%87%AA%E5%B8%A6%20database%20%E4%BE%A7%E8%BE%B9%E6%A0%8F%E7%94%9F%E6%88%90JavaBean/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://steve6636.gitee.io" target="_blank">小波的博客</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E5%B7%A5%E5%85%B7%E7%AF%87/">工具篇</a></div><div class="post_share"><div class="social-share" data-image="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button button--animated"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/img/wechat.jpg" target="_blank"><img class="post-qr-code-img" data-lazy-src="/img/wechat.jpg" alt="wechat"/></a><div class="post-qr-code-desc">wechat</div></li><li class="reward-item"><a href="/img/alipay.jpg" target="_blank"><img class="post-qr-code-img" data-lazy-src="/img/alipay.jpg" alt="alipay"/></a><div class="post-qr-code-desc">alipay</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2021/05/26/%E4%BB%8E%E9%9B%B6%E5%BC%80%E5%A7%8B%E6%90%AD%E5%BB%BA-Hexo-%E5%8D%9A%E5%AE%A2/"><img class="prev-cover" data-lazy-src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">从零开始搭建 Hexo 博客</div></div></a></div><div class="next-post pull-right"><a href="/2021/05/10/Windows-Terminal-install-settings/"><img class="next-cover" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210929231042.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Windows Terminal安装与美化</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/2021/05/27/Cmder-install-settings/" title="Cmder 安装与配置"><img class="cover" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210930083746.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-05-27</div><div class="title">Cmder 安装与配置</div></div></a></div><div><a href="/2021/07/04/IDEA debug 使用教程/" title="IDEA debug 使用教程"><img class="cover" data-lazy-src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-07-04</div><div class="title">IDEA debug 使用教程</div></div></a></div><div><a href="/2021/03/26/Typora-常用快捷键-官网翻译/" title="Typora-常用快捷键-官网翻译"><img class="cover" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210808160612.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-03-26</div><div class="title">Typora-常用快捷键-官网翻译</div></div></a></div><div><a href="/2021/05/10/Windows-Terminal-install-settings/" title="Windows Terminal安装与美化"><img class="cover" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210929231042.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-05-10</div><div class="title">Windows Terminal安装与美化</div></div></a></div><div><a href="/2021/08/07/为PDF电子书添加目录/" title="为PDF电子书添加目录"><img class="cover" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210808154637.jpeg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-08-07</div><div class="title">为PDF电子书添加目录</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="card-info-avatar is-center"><img class="avatar-img" data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20210327175316.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">Steve</div><div class="author-info__description">路漫漫其修远兮，吾将上下而求索</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">26</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">11</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">9</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/forkiller"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/forkiller" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:1518109600@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">冷灯看剑，剑上几番功名？炉香无须计苍生，纵一川烟逝，万丈云埋，孤阳还照古陵</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81%E8%BF%9E%E6%8E%A5%E6%95%B0%E6%8D%AE%E5%BA%93"><span class="toc-text">1、连接数据库</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-%E6%95%B0%E6%8D%AE%E5%BA%93%E4%B8%AD%E7%9A%84%E7%BB%93%E6%9E%84"><span class="toc-text">2.数据库中的结构</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#2-1%E3%80%81%E5%B7%A5%E5%85%B7%E6%A0%8F%E4%BB%8B%E7%BB%8D"><span class="toc-text">2.1、工具栏介绍</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-2%E6%9F%A5%E7%9C%8B%E6%95%B0%E6%8D%AE%E8%A1%A8%E8%A7%86%E5%9B%BE"><span class="toc-text">2.2查看数据表视图</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-3%E3%80%81Data-Extractors-%E6%95%B0%E6%8D%AE%E6%8F%90%E5%8F%96%E5%99%A8%E4%BB%8B%E7%BB%8D"><span class="toc-text">2.3、Data Extractors 数据提取器介绍</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81%E7%94%9F%E6%88%90%E5%AE%9E%E4%BD%93%E7%B1%BB"><span class="toc-text">3、生成实体类</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#3-1-%E9%85%8D%E7%BD%AE-groovy-%E6%96%87%E4%BB%B6"><span class="toc-text">3.1 配置 .groovy 文件</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1%EF%BC%89%E6%89%93%E5%BC%80-groovy-%E6%96%87%E4%BB%B6%E6%89%80%E5%9C%A8%E7%9B%AE%E5%BD%95"><span class="toc-text">1）打开 .groovy 文件所在目录</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2%EF%BC%89%E6%96%B0%E5%BB%BA-groovy-%E6%96%87%E4%BB%B6"><span class="toc-text">2）新建 .groovy 文件</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3%EF%BC%89%E9%87%8D%E5%90%AF-IDEA"><span class="toc-text">3）重启 IDEA</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#4%EF%BC%89%E6%BC%94%E7%A4%BA%E6%95%88%E6%9E%9C"><span class="toc-text">4）演示效果</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#5%EF%BC%89%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9"><span class="toc-text">5）注意事项</span></a></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2022/03/06/Mysql%E7%9A%84%E4%BC%98%E5%8C%96-%E8%87%AA%E6%88%91%E6%8F%8F%E8%BF%B0/" title="MySQL 的优化.md"><img data-lazy-src="https://img2.baidu.com/it/u=1814268193,3619863984&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=632&amp;h=500" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="MySQL 的优化.md"/></a><div class="content"><a class="title" href="/2022/03/06/Mysql%E7%9A%84%E4%BC%98%E5%8C%96-%E8%87%AA%E6%88%91%E6%8F%8F%E8%BF%B0/" title="MySQL 的优化.md">MySQL 的优化.md</a><time datetime="2022-03-06T14:54:18.000Z" title="发表于 2022-03-06 22:54:18">2022-03-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/03/06/MySQL%E6%95%B0%E6%8D%AE%E5%BA%93%E5%A4%87%E4%BB%BD%E5%91%BD%E4%BB%A4-20210722/" title="MySQL 数据库备份命令.md"><img data-lazy-src="https://img2.baidu.com/it/u=1814268193,3619863984&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=632&amp;h=500" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="MySQL 数据库备份命令.md"/></a><div class="content"><a class="title" href="/2022/03/06/MySQL%E6%95%B0%E6%8D%AE%E5%BA%93%E5%A4%87%E4%BB%BD%E5%91%BD%E4%BB%A4-20210722/" title="MySQL 数据库备份命令.md">MySQL 数据库备份命令.md</a><time datetime="2022-03-06T14:47:18.000Z" title="发表于 2022-03-06 22:47:18">2022-03-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/03/06/Git-study/" title="git 笔记.md"><img data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20220306225241.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="git 笔记.md"/></a><div class="content"><a class="title" href="/2022/03/06/Git-study/" title="git 笔记.md">git 笔记.md</a><time datetime="2022-03-06T14:47:18.000Z" title="发表于 2022-03-06 22:47:18">2022-03-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/03/06/Junit&amp;jdk8%E6%96%B0%E7%89%B9%E6%80%A7/" title="jdk8 新特性.md"><img data-lazy-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.05sun.com%2Fup%2F2006%2F2020611101156542640.png&amp;refer=http%3A%2F%2Fimg.05sun.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1649170568&amp;t=1d3529a6cb00dac37673cce4473d9a89" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="jdk8 新特性.md"/></a><div class="content"><a class="title" href="/2022/03/06/Junit&amp;jdk8%E6%96%B0%E7%89%B9%E6%80%A7/" title="jdk8 新特性.md">jdk8 新特性.md</a><time datetime="2022-03-06T14:47:18.000Z" title="发表于 2022-03-06 22:47:18">2022-03-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/03/06/Docker%20%E7%AC%94%E8%AE%B0_20210404/" title="Docker 笔记.md"><img data-lazy-src="https://gitee.com/forkiller/picture/raw/master/img/20220306223850.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Docker 笔记.md"/></a><div class="content"><a class="title" href="/2022/03/06/Docker%20%E7%AC%94%E8%AE%B0_20210404/" title="Docker 笔记.md">Docker 笔记.md</a><time datetime="2022-03-06T14:29:58.000Z" title="发表于 2022-03-06 22:29:58">2022-03-06</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg')"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2022 By Steve</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="font-plus" type="button" title="放大字体"><i class="fas fa-plus"></i></button><button id="font-minus" type="button" title="缩小字体"><i class="fas fa-minus"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/medium-zoom/dist/medium-zoom.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.autoSpacingPage()
  else {
    getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.autoSpacingPage()
      })
  }
}

function panguInit () {
  if (false){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><script src="/js/search/local-search.js"></script><div class="js-pjax"></div><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = true;
document.body.addEventListener('input', POWERMODE);
</script><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js" async="async" mobile="true"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = [
  'title',
  '#config-diff',
  '#body-wrap',
  '#rightside-config-hide',
  '#rightside-config-show',
  '.js-pjax'
]

if (false) {
  pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
}

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  if (typeof gtag === 'function') {
    gtag('config', '', {'page_path': window.location.pathname});
  }

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // Analytics
  if (false) {
    MtaH5.pgv()
  }

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})


document.addEventListener('pjax:send', function () {
  typeof preloader === 'object' && preloader.initLoading()
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>